Method and system for computing distance measures on a quantum computer

ABSTRACT

Nearest neighbor distances are obtained by coherent majority voting based on a plurality of available distance estimates produced using amplitude estimation without measurement in a quantum computer. In some examples, distances are Euclidean distances or are based on inner products of a target vector with vectors from a training set of vectors. Distances such as mean square distances and distances from a data centroid can also be obtained.

FIELD

The disclosure pertains to estimating distances with quantum computers.

BACKGROUND

Nearest neighbor classification can be used to solve real world problemssuch as determining whether a handwritten number is even or odd, orwhether a handwritten marking is a letter, a number, a lower caseletter, an uppercase letter, or other symbol. Conventional computationmethods for performing such classifications tend to require largenumbers of processing steps. Quantum computing methods can permit morerapid solution of some conventional computational problems such assearching and factorization. Quantum computing methods forclassification have been based on mean data values. In many practicalexamples, mean data values are not suitable, especially if data valueshave irregular or complex distributions. For example, in many practicalapplications, success probabilities of only about 50% are obtained withmean value based methods, rendering such methods no more reliable thanflipping a coin. Improved methods for classification using quantumcomputers are needed.

SUMMARY

This Summary is provided to introduce a selection of concepts in asimplified form that are further described below in the DetailedDescription. This Summary is not intended to identify key features oressential features of the claimed subject matter, nor is it intended tobe used to limit the scope of the claimed subject matter.

The disclosed methods and apparatus address problems associated withclustering, classification, and distance measure computations on aquantum computer. The disclosed approaches can provide end-to-endsolutions in which such computations are performed with a quantumcomputer. In addition, decision problems can be solved using a number ofqueries to a quantum oracle that is not explicitly dependent on thenumber of features in a feature vector. The disclosed approaches alsoare suitable for a wider range of applications than conventionalmethods. Quantum computing methods permit determination of innerproducts and Euclidean distances between elements of data sets. Anearest neighbor to a particular data point can be determined, whereinthe neighbor distance is based on a Euclidean distance or an innerproduct of vectors defined by the data points. In addition, data valuescan be assigned to one or more data sets corresponding to a nearestcluster of data points. Distances are obtained based on amplitudeestimation without measurement, and a median value of a plurality ofvalues is selected.

The foregoing and other features, and advantages of the disclosedtechnology will become more apparent from the following detaileddescription, which proceeds with reference to the accompanying figures.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram illustrating a quantum method for determininga nearest neighbor distance or identifying a nearest neighbor to atarget data point.

FIG. 2 illustrates a quantum circuit that can be used to obtain an innerproduct.

FIG. 3A illustrates a method of estimating a nearest neighbor distanceusing amplitude estimation and coherent majority voting.

FIG. 3B illustrates a representative quantum circuit for amplitudeestimation.

FIG. 4 illustrates a representative example in which five median valueestimates include three correct values and two incorrect values.

FIG. 5 illustrates a quantum method of determining a nearest neighborestimate using a Dürr-Høyer minimization, amplitude estimation withoutmeasurement, and coherent majority voting.

FIG. 6 further illustrates coherent majority voting and amplitudeestimation without measurement.

FIG. 7 illustrates a method of determining an mth smallest value usingamplitude estimation without measurement, and coherent majority voting.

FIG. 8 illustrates a target data point situated among two data clusters.

FIG. 9 illustrates a method of assigning a target data point to a datacluster.

FIG. 10 illustrates a representative quantum minimization circuit.

FIG. 11 is a block diagram of a representative computing environment inwhich the disclosed methods can be implemented.

FIG. 12 is a block diagram of a representative computing environmentthat includes classical and quantum processing.

DETAILED DESCRIPTION

As used in this application and in the claims, the singular forms “a,”“an,” and “the” include the plural forms unless the context clearlydictates otherwise. Additionally, the term “includes” means “comprises.”Further, the term “coupled” does not exclude the presence ofintermediate elements between the coupled items.

The systems, apparatus, and methods described herein should not beconstrued as limiting in any way. Instead, the present disclosure isdirected toward all novel and non-obvious features and aspects of thevarious disclosed embodiments, alone and in various combinations andsub-combinations with one another. The disclosed systems, methods, andapparatus are not limited to any specific aspect or feature orcombinations thereof, nor do the disclosed systems, methods, andapparatus require that any one or more specific advantages be present orproblems be solved. Any theories of operation are to facilitateexplanation, but the disclosed systems, methods, and apparatus are notlimited to such theories of operation.

Although the operations of some of the disclosed methods are describedin a particular, sequential order for convenient presentation, it shouldbe understood that this manner of description encompasses rearrangement,unless a particular ordering is required by specific language set forthbelow. For example, operations described sequentially may in some casesbe rearranged or performed concurrently. Moreover, for the sake ofsimplicity, the attached figures may not show the various ways in whichthe disclosed systems, methods, and apparatus can be used in conjunctionwith other systems, methods, and apparatus. Additionally, thedescription sometimes uses terms like “produce” and “provide” todescribe the disclosed methods. These terms are high-level abstractionsof the actual operations that are performed. The actual operations thatcorrespond to these terms will vary depending on the particularimplementation and are readily discernible by one of ordinary skill inthe art.

In some examples, values, procedures, or apparatus' are referred to as“lowest”, “best,” “minimum,” or the like. It will be appreciated thatsuch descriptions are intended to indicate that a selection among manyused functional alternatives can be made, and such selections need notbe better, smaller, or otherwise preferable to other selections.

A variety of practical problems can be addressed with the disclosedmethods and apparatus. In addition to processing hand writtencharacters, nearest neighbor classification can be used to identifychemical compounds that are similar to a target compound, recognizepatterns in videos, still images, audio, or other types of data.Defective items can be identified in a manufacturing process or othertypes of product selection can be performed. In some cases, a particulardata point or data vector is assigned to a data set based on estimationof a closeness of the data point or vector to the elements of the set.For example, a handwritten character can be associated with a set ofeven numbers or a set of odd numbers based on the distance between thetest character and the estimate of the closest odd or even character.

In the disclosed examples, quantum methods permit determination ofnearest neighbors. For such determinations, suitable quantum functionsare used to obtain distance estimates for inner products or Euclideandistances. Other quantum procedures can be used as well, and a minimumvalue of any suitably defined quantum function that can be applied toelements of a data set can be used. Particular examples pertaining toquantum determination of inner products, Euclidean distances, datacentroids, and mean square distances from a data centroid are described,but these functions are not to be taken as limiting the applicability ofthe disclosed methods and apparatus. Any distance metric that can beexpressed as a quantum function can be used.

In still other examples, distances are obtained by processing input datawith, for example, a quantum computer to establish chemical or otherproperties of compositions. Data can also be represented as classicalbit strings, and arbitrary metric functions can be defined to serve asdistances functions for nearest neighbor based classification. Ingeneral, the disclosed methods are applicable to machine learning inwhich one or more training data sets are available and each trainingdata point consists of a vector of feature values and an associatedlabel, and a target data set or target data point consists of a vectorof feature values and the machine learning task is to assign a label isto the target data points.

In some disclosed examples, minimum distances are used to identify aparticular closest data vector and associate a data vector with one ormore data sets. In other examples, maximum distances are determined, anddata vectors are assigned and identified based on maximum distances. Instill other examples, intermediate distances or statistical distancesare used.

For convenience, collections of data are referred to as data sets, andelements of data sets are referred to as data points or data vectors. Noparticular arrangement of data values is required, and data vectors aretypically arranged as one-dimensional arrays, but other arrangements canbe used. In some applications, determining a distance of a particulardata point (sometimes referred to herein as a “target data point” or“target vector”) from a data point or set of data points is used toassign a target data point to a particular data set. Such a data set canbe referred to as a training set. In some examples, multiple data setsare evaluated, or a single data set is divided into two or more dataclusters. Distances from such clusters can be found and assignment of atarget data point to one or more such data clusters can be made asdescribed below. In distance estimations, particularly those based oninner products, data vectors are generally normalized to have unitlengths. A data set can be divided into clusters and distancesnormalized based on a variance of distances within clusters. A targetvector can then be assigned to a data set based on distances associatedwith clusters. This can lead to superior label assignment for a targetvector under certain circumstances. In some examples, distances are usedto identify a nearest neighbor or assign a target data vector to a set,but distances are not reported. For example, a data vector can bespecified by an index that identifies the data vector.

Nearest Neighbor Quantum Searching

In many applications, a nearest neighbor to a particular target datapoint or data vector is obtained based on distances from the target toother data points or vectors, or sets of data points or vectors. Nearestneighbor classification typically assigns a data point u to a closestdata set of two or more data sets based on a selected distancespecification. For example, a data point u is assigned to a data set {A}and not to a data set {B} if min|u−a|≦min|u−b| for all a ∈ {A}, b ∈ {B},wherein |x−a| is defined as a distance between x and a. Distances |x−a|can be determined in a variety of ways. In some disclosed examples,distances between N-dimensional data points x and a are determined basedon a Euclidian distance defined as |x−a|=√{square root over(Σ(x_(i)−a_(i))²)}, wherein x=(x₁,x₂, . . . , x_(N)) and a=(a₁,a₂, . . ., a_(N)). Distances |x−a| can also be estimated based on a scalar orinner product so that the distance |x−a|=1−x·a. Distances based on innerproducts are typically applied to normalized data vectors, and in somecases, data normalization is performed prior to distance determination.Finding a nearest neighbor involves finding one or more values or setsof values of a such that the distance |x−a| is minimized. Forevaluations based on the inner product, minimization of the distance1−x·a is equivalent to maximizing the scalar product x·a.

While the examples are generally described with reference to distanceminimization, any processing of data values to determine a maximum cangenerally be transformed into an equivalent minimization procedure.Thus, while the examples are described with reference to minimization,the same procedures can be used in maximization by transformation of adistance or other function appropriately.

A quantum computational method 100 of determining a nearest neighbor isillustrated in FIG. 1. At 102, a particular quantum distance procedureis selected, based in part on a selection of a distance type at 103.Distance determinations generally employ a quantum algorithm P: |j

|0

→|j

|v_(j)

for initial state preparation, for any j>0. A distance ∥|v₀

−|v_(j)

∥ between data vectors represented as quantum states |v₀

,|v_(j)

, respectively, can be obtained based on application of a quantumdistance algorithm A to the output of quantum algorithm P, wherein thenotation |j

|v_(j)

represents a combined quantum state. In some examples, selection of adistance type at 103 can also be used to specify a suitable quantumcircuit for distance calculations. At 104, data for use in nearestneighbor determinations is received, typically as a set of M vectors ofdimension N, wherein M, N are positive integers. This data can beprovided directly, or through a quantum subroutine that providescomponents of the vectors. At 106, a number of votes k, wherein k is apositive integer, and an error tolerance c are received. The use of thenumber of votes k and the error tolerance ε are discussed in more detailbelow. Distance and minimization computations are performed at 108, andone or more of an estimated minimum or an index identifying a data valueor vector associated with the minimum is provided at 110. The estimateof min∥|v₀

−|v_(j)

∥ is determined based on the distance algorithm A so as to be accuratewithin the error tolerance ε.

In some examples, distances are determined based on an inner product.FIG. 2 illustrates a representative quantum circuit 200 that can be usedto determine an inner product of amplitudes associated with quantumstates 204, 206. A qubit 202 in a zero state is coupled to a Hadamardgate 210 whose output is coupled as a control input to a controlled swapgate 214. A second Hadamard gate 212 is coupled to the qubit 202 and theresultant state from the quantum circuit 200 can be written as:

½|0

(|φ

|ψ

+|ψ

|φ

)+½|1

(|φ

|ψ

−|ψ

|φ

).

Measurement of the first qubit of this output state permitsdetermination of a probability of the |0

state P(0), wherein

${P(0)} = \left. {\frac{1}{2} + \frac{1}{2}} \middle| {\sum\limits_{i}{\psi_{i}\phi_{i}}} \middle| {}_{2}. \right.$

Determination of P(0) thus permits determination of the absolute valueof the inner product

${\langle\left. \psi \middle| \phi \right.\rangle} = {\sum\limits_{i}{\phi_{i}{\psi_{i}.}}}$

The inner product can also be found directly by using the followingsubstitution in the above method, for states |φ

and |ψ

:

$\left. {\left. \left. {\left| \varphi \right.\rangle}\rightarrow\frac{\left. {\left. {\left. {{\left. \left( \left| 0 \right.\rangle \right. \middle| 0 \right.\rangle} +} \middle| 1 \right.\rangle} \middle| \varphi \right.\rangle} \right)}{\sqrt{2}} \right. \middle| \psi \right.\rangle}\rightarrow{\frac{\left. {\left. {\left. {{\left. \left( \left| 0 \right.\rangle \right. \middle| 0 \right.\rangle} +} \middle| 1 \right.\rangle} \middle| \psi \right.\rangle} \right)}{\sqrt{2}}.} \right.$

Referring to FIG. 3A, a method 300 of obtaining a distance estimateincludes receiving a distance estimate procedure at 302, a set of MN-dimensional vectors provided by a function that accesses components ofthe vectors at 304 along with an index of a target vector, and a numberof votes k and an error tolerance ε at 306. Typically, an index of avector to be compared with a target vector |v₀

is input as a quantum state |j

. At 310 a value of a counter i is initialized, and at 312, amplitudeestimation is applied to a vector A(N,|j

) using a quantum register of size

$R \sim {\frac{1}{ɛ}.}$

In amplitude estimation without measurement, a result is not measuredand a projection operator is not used so that the quantum state ispreserved. A result is stored as

${\left. {{{{\left| \psi_{i} \right.\rangle} = \left. a \middle| y_{i} \right.}\rangle} + \sqrt{\left. {1 -} \middle| a \right|^{2}}} \middle| y_{i}^{\bot} \right.\rangle},$

wherein each y_(i) stores a distance ∥|v₀

−|v_(j)

∥, wherein |y_(i)

corresponds to a correct answer and |y_(i) ^(⊥)

corresponds to a quantum superposition of incorrect answers returned byamplitude estimation without measurement. Typically, a²˜0.81, indicatingamplitude estimation has reasonable probability of failure. At 316, theindex i is incremented, and additional |ψ_(i)

are determined in the same manner. This continues until the index i=k sothat k states |ψ_(i)

are available.

As noted above, amplitude estimation stores |a|² with an 81% probabilityof providing a correct result. To obtain an improved probability ofsuccess, coherent majority voting is used in a median operation at 320.For example, with the k values of |ψ_(i)

,

|median(ψ₁, . . . , ψ_(k))

←Median(|ψ₁

, . . . , |ψ_(k)

)

is returned at 320. Even if a single value has only a probability of 81%of being correct, a median value of a set of results will produce asubstantially improved likelihood of success. At 324, a distanceestimate is returned.

FIG. 3B illustrates a representative circuit 350 for amplitudeestimation. A register 352 is initialized to correspond to a |0

state and is coupled to an L-dimensional quantum Fourier transformoperator F_(L) 354. A controlled Q_(j) operator applies j Groveriterations to a target state if the register 352 has value j. An inverseFourier transform operator F_(L)* is then applied to produce output |y

. (The notation * is used to denote the conjugate transpose of theoperator F_(L)).

The benefits of coherent majority voting are illustrated in FIG. 4. Fiveresults 401-405 are obtained, with only three results being the correctvalue. Nevertheless, a median value of these three correct and twoincorrect values is the correct distance value as the correct value isthe majority value. Thus, even with quantum computational proceduresthat provide a limited probability of success, but have a greaterprobability of success than failure, a correct result can be obtainedwith success probability arbitrarily close to 1.

The method of FIG. 3A is summarized below in Table 1 as a quantumdistance procedure QDIST(N, j, k, ε).

TABLE 1 Pseudocode for Quantum Distance Determination Input: Dimensionof vectors N. Input: Number of votes used in majority voting scheme k.Input: Error tolerance ε. Input: Quantum algority,

 : |j 

  |0 

 

 |j 

 |v_(j) 

 for any j, quantum algorithm

 such that for any j > 0 ∥ |v_(o) 

 − |v_(j) 

 ∥ can be  inferred by sampling from the output of

 (j). Output: Quantum state that contains an ε-close approximation to ∥|v₀ 

 − |v_(j) 

 ∥, where ∥ · ∥ is the distance measure computed  by

 .  function QDIST(N, j, k, ε)   for i ∈ 1 → k do    Apply amplitudeestimation on

 (N, |j 

 ) using a register of size R α 1/ε and without measuring the result.    $\begin{matrix}{{{Store}\mspace{14mu} {result}\mspace{14mu} {as}\mspace{14mu} {quantum}\mspace{14mu} {state}\mspace{14mu} \text{}\psi_{k}} = {{{a\text{}y_{k}} + {\sqrt{{1 - {{a}^{2}\text{}y\frac{1}{k}.}}\mspace{11mu}}\; {Each}\mspace{14mu} y_{k}\mspace{14mu} {stores}\mspace{11mu} {\; {{\text{}v_{0}} - {\text{}v_{j}}}}\mspace{14mu} {with}\mspace{14mu} {a}^{2}}} \approx {81\%}}} \\{{\; \text{}y\frac{1}{k}\mspace{14mu} {refers}\mspace{14mu} {to}\mspace{14mu} {an}\mspace{14mu} {incorrect}\mspace{14mu} {answer}\mspace{14mu} {that}\mspace{14mu} {is}\mspace{14mu} {yielded}}\mspace{20mu} \mspace{191mu} {{by}\mspace{20mu} {the}\mspace{14mu} {amplitude}\mspace{14mu} {estimation}\mspace{14mu} {{algorithm}.}}}\end{matrix}$   end for   |median(ψ₁, . . . , ψ_(k)) 

 ← Median(|ψ₁ 

 , . . . , |ψ_(k) 

 ).   Undo all steps previous to the median calculation step above.  return |median(ψ₁, . . . , ψ_(k)) 

 .  end functionAs shown in Table 1, distance determination is not limited to anyparticular definition of distance but is based on application of asuitable quantum distance operation (shown as A in Table 1). After thecoherent majority voting at 320, steps associated with amplitudeestimation are undone at 322. Because operations associated withamplitude estimation without measurement are unitary, the operations canbe reversed to arrive at the initial distribution of states.

A minimum distance value or an index associated with a minimum distancecan be obtained using a Dürr-Høyer minimization procedure illustrated inFIG. 5. At 502, a threshold index y is chosen uniformly at random fromamong all the vectors of a data set. At 504, an iterative procedure isinitiated. At 506, a quantum memory is initialized as a sum over allstates for the selected y with a uniform weighting. At 508, all statesfor which D[j] is less than D[y] are marked, wherein D is a suitabledistance function such as QDIST as discussed above. A quantum searchmethod such as a Grover search is applied at 510. At 512, the thresholdindex y is assigned a revised value based on the result of the search at510. In some cases, a limited number of additional searches at 510 isneeded. Typically, about 22.5√{square root over (M)}+1.4(log₂ N)²searches are sufficient, and additional searching may becounterproductive. At 514, an outcome y′ is associated with anobservation of a first register, and if the distance associated with y′is less than that associated with y, the index value y′ is provided asan output, designating the y′ th vector of the data set. At 515, adistance associated with the index can be output, instead of or inaddition to the index value y′. The Dürr-Høyer method is described infurther detail in Dürr and Høyer, “A quantum algorithm for finding theminimum,” arXiv:quant-ph/90607014v2 (Jan. 7, 1999), which isincorporated herein by reference.

The method of FIG. 5 is summarized in Table 2 below.

TABLE 2 Pseudocode for a Quantum Distance Minimization Method Input:Number of vectors M. Input: Dimension of vectors N. Input: Number ofvotes used in majority voting scheme k. Input: Error tolerance ε. Input:Quantum algorithm, 

 : |j 

  |0 

 

 |j 

 |υ_(j) 

 for any j, quantum algorithm 

 such that for any j > 0 || |υ_(O) 

 − |υ_(j) 

 || can be inferred by sampling from the output of 

 . Output: Estimate of min_(j) || |υ_(O) 

 − |υ_(j) 

 || that is accurate within error ε, where || · || is the distancemeasure computed by 

 . function QMINDIST(N, M, k, ε) Apply the Dürr, Høyer minimizationalgorithm to find the minimum value of median(ψ₁, . . . , ψ_(k)) outputby QDist(N, ·, k, ε). return Estimate of min_(j) || |υ_(O) 

 − |υ_(j) 

 || yielded by minimization algorithm. end function

The method of FIG. 5 can be used with various quantum distancealgorithms. As discussed above, the function QDIST receives a distancedefinition as an input. Typical distances used in QDIST are based oninner products or Euclidean distances.

Amplitude estimation is further illustrated in FIG. 6. At 602, aninitial counter j is initialized, and at 604, amplitude estimationwithout measurement is applied. A result is retained as |y_(j)

. Additional values are obtained if j<k as determined at 608. Thecounter j is incremented at 610 and additional |y_(j)

results are obtained. Once k values of |y

are found, a median is computed at 612 based on all of the |y

results.

Quantum Methods of Determining Medians and m^(th) Smallest Elements

The nearest neighbor determinations discussed above are associated withminimizing distances between data vectors. In other examples, medians orother values can be determined. An ε-approximate median of a sequence Xof n numbers is a number x_(i) such that the number of x_(j) greaterthan x_(i) and less than x_(i) are less than (1+ε)n/2. A Δ-approximatek^(th) smallest element is a number x_(i) that is the k^(th) smallestelement of X between k−Δ and k+Δ. Data points associated with, forexample, m^(th) smallest distances can be found as shown in FIG. 7.Processing is similar to that of FIG. 5 above, but at 706 an m^(th)smallest procedure is executed, and a resulting estimate is provided asan output at 708. A suitable m^(th) smallest procedure is described inNayak and Wu, “The quantum query complexity of approximating the medianand related statistics,” available at arXiv:quant-ph/9804066v2 (Nov. 15,1998), which is incorporated herein by reference.

Distances to Cluster Centroids

As shown above, quantum computers and circuits can be arranged todetermine a nearest neighbor or an m^(th) closest neighbor to a targetvector. In some applications, a target vector is evaluated to determineif it should be associated with a particular data cluster. For example,as shown in FIG. 8, a target data point 802 has values such that thetarget data point 802 is situated among data clusters 804, 806.Assignment or association of the target data 802 point to a particulardata cluster can be complicated due to the complex arrangements of thedata clusters 804, 806 or the location of the data point 802.

A quantum computing method of assigned in data point to a particulardata set or data cluster from among a plurality data sets or dataclusters is illustrated in FIG. 9. At 904, a number of vectors M and adimension N of the vectors is received. A number of data clusters M′ isreceived at 906, and at 910, a particular cluster number p is input as aquantum state |p

. A quantum function is provided at 908 such that |p

|j

|0

→|p

|j

|v_(j) ^(p)

, wherein |v_(j) ^(p)

is vector in the cluster p and |v_(j) ^(p)

=|v₀

for all p. At 911, an operator V is applied so that:

${\left. {\left. {\left. {{\left. {\left. {{{\left. \left. {\left| \psi \right.\rangle}\leftarrow V \right. \middle| 0 \right.\rangle} = \left. \frac{1}{\sqrt{2}} \middle| p \right.}\rangle} \middle| 0 \right.\rangle} \middle| 0 \right.\rangle} + {\sqrt{\frac{M^{\prime}}{2M}}\sum\limits_{j = 1}^{\frac{M}{M^{\prime}}}}}\; \middle| p \right.\rangle} \middle| j \right.\rangle} \middle| 0 \right.\rangle}.$

At 912, a state preparation procedure is executed so that

${\left. {\left. {\left. {{\left. {\left. {{{\left. \left. {\left| \psi \right.\rangle}\leftarrow P \right. \middle| \psi \right.\rangle} = \left. \frac{- 1}{\sqrt{2}} \middle| p \right.}\rangle} \middle| 0 \right.\rangle} \middle| v_{0} \right.\rangle} + {\sqrt{\frac{M^{\prime}}{2M}}\sum_{j - 1}^{\frac{M}{M^{\prime}}}}} \middle| p \right.\rangle} \middle| j \right.\rangle} \middle| v_{j} \right.\rangle}.$

At 914, the inverse of the operator V is applied, and at 916, and anoutput state is provided such that the probability of measuring a firstregister to be zero is proportional to a square of the Euclideandistance:

$\left. {\left. {{\left. {{P(0)} \propto} \middle| v_{0} \right.\rangle} - {\frac{M^{\prime}}{M}\sum\limits_{j = 1}^{\frac{M}{M^{\prime}}}}}\; \middle| v_{j}^{p} \right.\rangle} \middle| {}_{2}. \right.$

At 917, a distance can be output based on the output quantum state.

The method of FIG. 9 is summarized in Table 3 below.

TABLE 3 Pseudocode for a Quantum Distance to Cluster Centroid MethodInput: Dimension of vectors N. Input: Number of vectors M. Input: Numberof clusters M′. Input: Cluster number p input as quantum state |p 

 . Input: Quantum algorithm: |p 

  |j 

  |0 

 

 |p 

 |j 

 |v_(j) ^((p)) 

 , where each |v_(j) ^((p)) 

 is one of the vectors in  cluster p and |v₀ ^((p)) 

 = |v₀ 

 for all p. Output: Quantum state in

 ^(M N) such that the probability of measuring the first register (theone of dimension M) to be 0 is  ${proportional}\mspace{14mu} {to}\mspace{14mu} {the}\mspace{14mu} {square}\mspace{14mu} {of}\mspace{14mu} {the}\mspace{14mu} {Euclidean}\mspace{14mu} {{dis}{tance}}\text{:}\mspace{11mu} {\quad\; {\quad\; {{{{\text{}v_{0}} - {\frac{M^{\prime}}{M}{\sum\limits_{j = 1}^{M/M^{\prime}}\; {\text{}v_{j}^{(p)}}}}}}.}}}$ function QCENTDIST(N, |p 

 , M, M′)   $\left. {\text{}\psi }\leftarrow{V\mspace{11mu} \text{}0\text{}p\mspace{14mu} \text{}0\; \text{}0\sqrt{\frac{M^{\prime}}{2\; M}}{\sum\limits_{j = 1}^{M}\; {\text{}p\mspace{14mu} \text{}j\; \text{}0.}}} \right.$  ${{Use}\mspace{14mu} {state}\mspace{14mu} {preparation}\mspace{14mu} {procedure}},{\left. {\mspace{14mu} {to}\mspace{14mu} {transform}\mspace{14mu} {state}\mspace{14mu} {as}\mspace{14mu} \text{}\psi }\leftarrow{\; \text{}\psi } \right. = {{\frac{- 1}{\sqrt{2}}\text{}p\mspace{14mu} \text{}0\; \text{}v_{0}} + {\sqrt{\frac{M^{\prime}}{2\; M}}{\sum\limits_{j = 1}^{M}\; {\text{}p\mspace{14mu} \text{}j\; \text{}v_{j}.}}}}}$      

 This creates the right superposition of states to give the average ofthe vectors and subtract off the vector |v₀ 

    

 Multiplying any of the terms above by −I (or more generally a complexphase does not change the algorithm's function   |ψ 

 ← V^(†) |ψ 

 .

 V^(†) is the inverse of V operation   return |ψ 

 end function

A method similar to that of FIG. 9 permits determination of a meansquare of distances between points within a cluster and a clustercentroid. In this method, a quantum function is used such that |q

|p

|j

|0

→|q

|p

|j

|v_(j) ^(p)

, for j>0, wherein |v_(j) ^(p)

is a vector in the cluster p and |v_(j) ^(p)

=|v₀

for all p, and |q

|p

|j

|0

→|q

|p

|j

|v_(q) ^(p)

and for j=0.

An operator V is applied so that:

$\left. {\left. {\left. {\left. {\left. {{\left. {\left. {{{\left. \left. {\left| \psi \right.\rangle}\leftarrow V \right. \middle| 0 \right.\rangle} = \left. {\frac{1}{\sqrt{2}}{\sum\limits_{q = 1}^{M\text{/}M^{\prime}}\; \left( \left| q \right.\rangle \right.}} \middle| p \right.}\rangle} \middle| 0 \right.\rangle} \middle| 0 \right.\rangle} + {\frac{1}{\sqrt{2M\text{/}M^{\prime}}}\sum\limits_{j = 1}^{M\text{/}M^{\prime}}}}\; \middle| q \right.\rangle} \middle| p \right.\rangle} \middle| j \right.\rangle} \middle| 0 \right.\rangle} \right)$

A state preparation procedure is executed so that |ψ

←P|ψ

and an inverse of V is applied, |ψ

←V^(†)|ψ

, so that an output is provided having a probability P(0) of themeasuring a first register to be zero is proportional to:

$\left. {\left. {{\left. {{P(0)} \propto \sum\limits_{q = 1}^{M\text{/}M^{\prime}}}\;||v_{q}^{p} \right.\rangle} - {\frac{M^{\prime}}{M}\sum\limits_{j = 1}^{M\text{/}M^{\prime}}}}\; \middle| v_{j}^{p} \right.\rangle} \middle| {}_{2}. \right.$

This method is summarized in Table 4 below.

TABLE 4 Pseudocode for a Quantum Mean Square Distances in Cluster Input:Dimension of vectors N. Input: Number of vectors M. Input: Number ofclusters M′. Input: Cluster number p input as quantum state |p 

 . Input: Quantum algorithm

 : |q 

 |p 

 |j 

 |0 

 

 |q 

 |p 

 |j 

 |v_(j) ^((p)) 

 for j > 0, where each |v_(j) ^((p)) 

 is one of the  vectors in cluster p and |v₀ ^((p)) 

 = |v₀ 

 for all p and

 : |q 

 |p 

 |j 

 |0 

 

 |q 

 |p 

 |j 

 |v_(q) ^((p)) 

 for j = 0. Output: Quantum state in

 ^(M N) such that the probability of measuring the first register (theone of dimension M) to be 0 is  ${proportional}\mspace{14mu} {to}\text{:}\mspace{20mu} \frac{M^{\prime}}{M}{\sum\limits_{q = 1}^{M/M^{\prime}}{{{{\text{}v_{q}^{(p)}} - {\frac{M^{\prime}}{M}{\sum\limits_{j = 1}^{M/M^{\prime}}{\text{}v_{j}^{(p)}}}}}}^{2}.}}$ function QMNSQDIST(N, |p 

 , M, M′)   $\left. {\text{}\psi }\leftarrow{V\mspace{11mu} \text{}0{\sum\limits_{q = 1}^{M/M^{\prime}}{\left( {\text{}q\mspace{14mu} \text{}p\; \text{}0\; \text{}0\frac{1}{\sqrt{2M\text{/}M^{\prime}}}{\sum\limits_{j = 1}^{M/M^{\prime}}{\text{}q\mspace{14mu} \text{}p\; \text{}j\; \text{}0}}} \right).}}} \right.$  Use state preparation procedure,

 to transform state as |ψ 

 ←

 |ψ 

 .         

 This creates the right superposition of states to give the average ofthe vectors and subtract off the vector |v₀ 

  |ψ 

 ← V^(†)|ψ 

 .                            

  V^(†) is the inverse of V operation   return |ψ 

 end function

Representative Quantum Computing Devices

Referring to FIG. 10, a representative quantum computing deviceadaptable to performing the disclosed methods includes a quantumdistance circuit selector 1002 that is configured to select or implementdistance circuits 1002A-1002D that can provide distance estimatesassociated with mean square distance with a cluster of data vectors, aninner produce, a Euclidean distance, or a distance to a clustercentroid, respectively, or other distances. A quantum minimizationcircuit 1004 is coupled to the quantum distance circuit 1002 and one ormore quantum registers 1010. Typically, the circuit 1004 is configuredto implement the Dürr-Høyer method. A quantum amplitude estimationcircuit 1006 and a quantum coherent voting circuit 1008 are also coupledso as to communicate with the quantum minimization circuit 1004.Circuits can be defined with any available qubits as is convenient. Inother examples, a quantum m^(th) nearest neighbor circuit is included inaddition to or instead of the quantum minimization circuit 1004.

Representative Computing Environments

FIG. 11 and the following discussion are intended to provide a brief,general description of an exemplary computing environment in which thedisclosed technology may be implemented. Although not required, thedisclosed technology is described in the general context of computerexecutable instructions, such as program modules, being executed by apersonal computer (PC). Generally, program modules include routines,programs, objects, components, data structures, etc., that performparticular tasks or implement particular abstract data types. Moreover,the disclosed technology may be implemented with other computer systemconfigurations, including hand held devices, multiprocessor systems,microprocessor-based or programmable consumer electronics, network PCs,minicomputers, mainframe computers, and the like. The disclosedtechnology may also be practiced in distributed computing environmentswhere tasks are performed by remote processing devices that are linkedthrough a communications network. In a distributed computingenvironment, program modules may be located in both local and remotememory storage devices.

With reference to FIG. 11, an exemplary system for implementing thedisclosed technology includes a general purpose computing device in theform of an exemplary conventional PC 1100, including one or moreprocessing units 1102, a system memory 11, and a system bus 506 thatcouples various system components including the system memory 1104 tothe one or more processing units 1102. The system bus 1106 may be any ofseveral types of bus structures including a memory bus or memorycontroller, a peripheral bus, and a local bus using any of a variety ofbus architectures. The exemplary system memory 1104 includes read onlymemory (ROM) 1108 and random access memory (RAM) 1110. A basicinput/output system (BIOS) 1112, containing the basic routines that helpwith the transfer of information between elements within the PC 1100, isstored in ROM 1108. As shown in FIG. 1, RAM 1110 can storecomputer-executable instructions for defining and coupling quantumcircuits such as quantum circuits implementing distance functions,amplitude estimation without measurement, coherent majority voting orother quantum circuit functions and procedures. In addition, somefunctions and procedures can be selected for implementation inconventional (non-quantum) computing hardware.

The exemplary PC 1100 further includes one or more storage devices 1130such as a hard disk drive for reading from and writing to a hard disk, amagnetic disk drive for reading from or writing to a removable magneticdisk, and an optical disk drive for reading from or writing to aremovable optical disk (such as a CD-ROM or other optical media). Suchstorage devices can be connected to the system bus 1106 by a hard diskdrive interface, a magnetic disk drive interface, and an optical driveinterface, respectively. The drives and their associated computerreadable media provide nonvolatile storage of computer-readableinstructions, data structures, program modules, and other data for thePC 1100. Other types of computer-readable media which can store datathat is accessible by a PC, such as magnetic cassettes, flash memorycards, digital video disks, CDs, DVDs, RAMs, ROMs, and the like, mayalso be used in the exemplary operating environment.

A number of program modules may be stored in the storage devices 1130including an operating system, one or more application programs, otherprogram modules, and program data. Storage of quantum syntheses andinstructions for obtaining such syntheses can be stored in the storagedevices 1130. For example, Grover iteration circuits, Dürr-Høyer methodcircuits, inner product circuits, and other circuit can be defined by aquantum computer design application and circuit definitions can bestored for use in design. A user may enter commands and information intothe PC 1100 through one or more input devices 1140 such as a keyboardand a pointing device such as a mouse. Other input devices may include adigital camera, microphone, joystick, game pad, satellite dish, scanner,or the like. These and other input devices are often connected to theone or more processing units 1102 through a serial port interface thatis coupled to the system bus 1106, but may be connected by otherinterfaces such as a parallel port, game port, or universal serial bus(USB). A monitor 1146 or other type of display device is also connectedto the system bus 1106 via an interface, such as a video adapter. Otherperipheral output devices, such as speakers and printers (not shown),may be included. In some cases, a user interface is display so that auser can input a circuit for synthesis, and verify successful synthesis.

The PC 1100 may operate in a networked environment using logicalconnections to one or more remote computers, such as a remote computer1160. In some examples, one or more network or communication connections1150 are included. The remote computer 1160 may be another PC, a server,a router, a network PC, or a peer device or other common network node,and typically includes many or all of the elements described aboverelative to the PC 1100, although only a memory storage device 1162 hasbeen illustrated in FIG. 11. The personal computer 1100 and/or theremote computer 1160 can be connected to a logical a local area network(LAN) and a wide area network (WAN). Such networking environments arecommonplace in offices, enterprise wide computer networks, intranets,and the Internet.

When used in a LAN networking environment, the PC 1100 is connected tothe LAN through a network interface. When used in a WAN networkingenvironment, the PC 1100 typically includes a modem or other means forestablishing communications over the WAN, such as the Internet. In anetworked environment, program modules depicted relative to the personalcomputer 1100, or portions thereof, may be stored in the remote memorystorage device or other locations on the LAN or WAN. The networkconnections shown are exemplary, and other means of establishing acommunications link between the computers may be used.

With reference to FIG. 12, an exemplary system for implementing thedisclosed technology includes computing environment 1200, wherecompilation into quantum circuits is separated from quantum processingthat uses the compiled circuits. The environment includes a quantumprocessing unit 1202 and one or more monitoring/measuring device(s)1246. The quantum processor executes quantum circuits that areprecompiled by classical compiler unit 1220 using one or more classicalprocessor(s) 1210. The precompiled quantum circuits are downloaded intothe quantum processing unit via quantum bus 1206. In some cases, quantumcircuits or portions thereof are predefined and stored as quantumcircuit definitions in a memory 1221. For example, quantum circuitsassociated with distance determinations, amplitude estimation,minimization, coherent majority voting, mth nearest neighbordeterminations, or other functions and procedures or portions thereofcan be stored in a library. A classical computer can be arranged tocontrol a quantum computer or one or more quantum circuits thereof. Theclassical computer can receive the output of a classical or quantumcomputer. Based on the received output, the classical computer indicateswhich quantum circuits are to be used in subsequent quantumcomputations, provides definitions of suitable quantum circuits, or, insome cases, controls additional classical computations.

With reference to FIG. 12, the compilation is the process of translationof a high-level description of a quantum algorithm into a sequence ofquantum circuits. Such high-level description may be stored, as the casemay be, on one or more external computer(s) 1260 outside the computingenvironment 1200 utilizing one or more memory and/or storage device(s)1262, then downloaded as necessary into the computing environment 1200via one or more communication connection(s) 1250. The high-leveldescription can be stored and interpreted classically, and a classicalcomputer can control the sequence of gates defined in a quantumcomputer. The high level description also controls application of gatesbased on initial, intermediate, or final data values.

In view of the many possible embodiments to which the principles of thedisclosed technology may be applied, it should be recognized that theillustrated embodiments are only preferred examples and should not betaken as limiting the scope of the disclosure. We therefore claim allthat comes within the scope and spirit of the appended claims.

1-20. (canceled)
 21. A method of preparing a quantum computation,comprising: with a computer, defining a first quantum circuit thatobtains an estimate of a distance between a target vector and a datavector from a set of data vectors; with the computer, defining a secondquantum circuit so as to produce a plurality of quantum statesassociated with corresponding distance estimates based on amplitudeestimation without measurement and provide a distance estimate based onthe plurality of amplitudes associated with quantum distances; andconfiguring a quantum computer based on the definition of the firstquantum circuit and the second quantum circuit.
 22. The method of claim21, wherein the second quantum circuit is configured to produce aquantum state corresponding to a median value of the distance estimates.23. The method of claim 21, wherein the second quantum circuit isconfigured to produce a median distance based on the quantum statecorresponding to the median value of the distance estimates.
 24. Themethod of claim 21, wherein the first quantum circuit determines theestimate of distance based on an inner product of the target vector andthe vectors of the set of data vectors.
 25. The method of claim 21,wherein the first quantum circuit determines the estimate of distance asa Euclidean distance between the target vector and the vectors of theset of data vectors.
 26. The method of claim 21, further comprisingdefining a third quantum circuit configured to determine a nearestneighbor vector of the set of data vectors associated with a minimumdistance between the target vector and the vectors of the set of datavectors.
 27. The method of claim 26, wherein the third quantum circuitis configured to determine the nearest neighbor distance based on theDürr-Høyer algorithm.
 28. The method of claim 21, further comprisingdefining a third quantum circuit configured to determine a nearestneighbor distance corresponding to a minimum distance between the targetvector and the vectors of the set of data vectors.
 29. The method ofclaim 21, further comprising defining a third quantum circuit configuredto determine an m^(th) smallest distance between the target vector andthe vectors of the set of data vectors or an index associated with thevector of the set of data vectors associated with the m^(th) smallestdistance.
 30. The method of claim 29, wherein the first quantum circuitdetermines the estimate of distance based on an inner product of thetarget vector and the vectors of the set of data vectors or as aEuclidean distance between the target vector and the vectors of the setof data vectors.
 31. The method of claim 21, further comprising defininga coherent voting quantum circuit that determines a number of votesassociated with the plurality of amplitudes so that the distanceestimate is based on the number of votes.
 32. A computer-readable mediumcomprising computer-executable instructions for a method of specifyingcircuits for a quantum computer, the method comprising: defining aquantum distance circuit configured to implement a quantum distanceoperator; and establishing an amplitude estimation quantum circuitconfigured to provide a plurality of amplitudes associated with quantumdistances based on the quantum distance operator, wherein the amplitudesare estimated without qubit measurement.
 33. The computer-readablemedium of claim 32, wherein the method further comprises defining acoherent voting quantum circuit that provides a distance estimate basedon the plurality of amplitudes associated with quantum distances. 34.The computer readable medium of claim 33, wherein the distance estimateis an estimate of a minimum distance.
 35. The computer readable mediumof claim 34, wherein the quantum distance circuit is configured toproduce distance as a Euclidean distance or an inner product.
 36. Thecomputer readable medium of claim 33, wherein the quantum distancecircuit produces a distance from a data centroid, or a mean squaredistance from a data centroid.
 37. The computer readable medium of claim32, wherein distance of the plurality of distances are associated withdata vectors in one or more training sets, and the method furthercomprises defining a circuit that assigns a target data vector to atleast one training set based on the plurality of distances.
 38. Thecomputer-readable of claim 32, wherein the method the further comprisesdefining a quantum circuit configured to identify a data vector from aset of training set that is associated with an mth smallest distancefrom a target data, wherein the mth smallest distance is obtained basedon the plurality of amplitudes provided by the amplitude estimationcircuit.
 39. The computer-readable medium of claim 38, wherein thequantum distance circuit produces a median value of a distance.
 40. Aquantum computer, comprising: a first quantum circuit configured todetermine a distance between a target vector and vectors from a set ofdata vectors, wherein the distance is a Euclidean distance or an innerproduct; a second quantum circuit configured to produce a plurality ofquantum states associated with corresponding distance estimates obtainedwith the first quantum circuit based on amplitude estimation withoutmeasurement; and a third quantum circuit configured to determine anearest neighbor distance between the target vector and the vectors ofthe set of data vectors by selecting a median value based on theplurality of quantum states and the corresponding distance estimates ofdistances between the target vector and the vectors of the set of datavectors.